package tr.edu.metu.is.mega.server.core;

import java.util.List;

import tr.edu.metu.is.mega.common.dto.BaseDTO;

/**
 * Interface for DTO-entity, entity-DTO conversion helper classes.
 * 
 * @param <T_DTO> type modifier for DTO
 * @param <T_ENTITY> type modifier for entity
 */
public interface DTOHelper<T_DTO extends BaseDTO, T_ENTITY extends BaseEntity> {

    /**
     * Converts entity to data transfer object.
     * 
     * @param entity entity instance
     * @return dto instance
     */
    T_DTO convertToDTO(T_ENTITY entity);

    /**
     * Converts entity to data transfer object.
     * 
     * @param entity entity instance
     * @return dto instance
     */
    T_DTO convertToDTORecursive(T_ENTITY entity);

    /**
     * Converts list of DTOs to list of entities.
     * 
     * @param entities list of entities
     * @return list of DTOs
     */
    List<T_DTO> toDTO(List<T_ENTITY> entities);

    /**
     * Converts data transfer object to entity.
     * 
     * @param dto data transfer object instance
     * @param entity instance
     */
    void toEntity(T_DTO dto, T_ENTITY entity);

    /**
     * Converts list of DTOs to list of entities.
     * 
     * @param dtos data transfer object list
     * @param classz class type of entity
     * @return list of entites
     */
    List<T_ENTITY> toEntity(List<T_DTO> dtos, Class<T_ENTITY> classz);

}
